package com.zhangshuo.patternDesign.obverser;


import java.util.Observable;

/**
 * Created by shuo.zhang on 2017-10-22.
 */
public class Writer extends Observable {

    private String name;

    public String getName() {
        return name;
    }



    public String getLastNovel() {
        return lastNovel;
    }


    private String lastNovel;

    public Writer(String name){
        super();
        this.name = name;
        WriterManager.getInstance().addWriter(this);
    }

    /**
     * 新写了一本书
     * @param novelName
     */
    public void addNovel(String novelName){
        if (novelName == null && novelName.trim().length() == 0)
            return ;
        lastNovel = novelName;
        setChanged();
        System.out.println(this.name + " 发行了新书 " + this.lastNovel);
        notifyObservers();
    }









}
